package test;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import expression.*;

public class ShermanSzetoIPTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void test1() {
		assertEquals( "1 3 4 5 2 * * * + 3 4 - 5 10 - - +"
				, InfixtoPostfixTranslator.eval("( 1 + ( 3 * ( 4 * ( 5 * 2 ) ) ) ) + ( ( 3 - 4 ) - ( 5 - 10 ) )"));
	}

	@Test
	public void test2() {
		assertEquals( "10 12 + 2 * 5 1 * + 1 -"
		, InfixtoPostfixTranslator.eval("( ( 10 + 12 ) * 2 + ( 5 * 1 ) ) - 1 "));
	}

	@Test
	public void test3() {
		assertEquals( "(1 2) ^ 3 10 * + 5 + 7 2 * 4 * + 4 - 7 - 0 + 0 -"
		, InfixtoPostfixTranslator.eval("(1 ^ 2) + 3 * 10 + 5 + 7 * 2 * 4 - 4 - 7 + 0 - 0"));
	}

	@Test
	public void test4() {
		assertEquals( "4 7 + 0 1 * 10 * -"
				, InfixtoPostfixTranslator.eval("4 + 7 - 0 * 1 * 10"));
	}

	@Test
	public void test5() {

		assertEquals( "0 0 + 0 0 * - 0 0 + - 10 +"
				, InfixtoPostfixTranslator.eval("0 + 0 - 0 * 0 - ( 0 + 0 ) + 10"));
	}

}
